package huzh.foundation.action;

import java.io.Serializable;
import java.util.HashMap;

import huzh.foundation.pool.objectpool.IObject;

/**
 *<p>title:BaseVO</p>
 *<p>description:</p>
 * @since 2014-6-21
 * @author huzh
 * @version 1.0
 */
public class BaseVO implements IObject, Serializable{
    /**serialVersionUID*/
    private static final long serialVersionUID = 3671920205703426388L;
    /**requestDataMap*/
    private HashMap<Object,Object> requestDataMap;
    /**responseDataMap*/
    private HashMap<Object,Object> responseDataMap;
    /**globalDataMap*/
    private HashMap<Object,Object> globalDataMap;

    /**
     * 
     */
    public BaseVO(){
        this.requestDataMap = new HashMap<Object,Object>();
        this.responseDataMap = new HashMap<Object,Object>();
        this.globalDataMap = new HashMap<Object,Object>();
    }

    /**
     * 
     */
    public void reset() {
        this.requestDataMap = null;
        this.responseDataMap = null;
        this.globalDataMap = null;
    }

    /**
     * @return
     */
    public HashMap<Object,Object> getRequestDataMap() {
        return this.requestDataMap;
    }

    /**
     * @param requestDataMap
     */
    public void setRequestDataMap(HashMap<Object,Object> requestDataMap) {
        this.requestDataMap = requestDataMap;
    }

    /**
     * @return
     */
    public HashMap<Object,Object> getResponseDataMap() {
        return this.responseDataMap;
    }

    /**
     * @param responseDataMap
     */
    public void setResponseDataMap(HashMap<Object,Object> responseDataMap) {
        this.responseDataMap = responseDataMap;
    }

    /**
     * @return
     */
    public HashMap<Object,Object> getGlobalDataMap() {
        return this.globalDataMap;
    }

    /**
     * @param globalDataMap
     */
    public void setGlobalDataMap(HashMap<Object,Object> globalDataMap) {
        this.globalDataMap = globalDataMap;
    }

    /**
     * @param key
     * @return
     */
    public Object getRequestObject(Object key){
        if (this.requestDataMap == null) {
            return null;
        }
        return this.requestDataMap.get(key);
    }

    /**
     * @param key
     * @return
     */
    public String getRequestParameter(String key) {
        if (this.requestDataMap == null) {
            return null;
        }
        return (String)getRequestObject(key);
    }

    /**
     * @param key
     * @param value
     */
    public void setRequestObject(Object key, Object value) {
        if (this.requestDataMap == null) {
            this.requestDataMap = new HashMap<Object,Object>();
        }
        this.requestDataMap.put(key, value);
    }

    /**
     * @param key
     * @return
     */
    public Object getResponseObject(Object key){
        if (this.responseDataMap == null) {
            return null;
        }
        return this.responseDataMap.get(key);
    }

    /**
     * @param key
     * @return
     */
    public String getResponseParameter(String key) {
        if (this.responseDataMap == null) {
            return null;
        }
        return (String)getResponseObject(key);
    }

    /**
     * @param key
     * @param value
     */
    public void setResponseObject(Object key, Object value) {
        if (this.responseDataMap == null) {
            this.responseDataMap = new HashMap<Object,Object>();
        }
        this.responseDataMap.put(key, value);
    }

    /**
     * @param key
     * @return
     */
    public Object getObject(Object key){
        if (this.globalDataMap == null) {
            return null;
        }
        return this.globalDataMap.get(key);
    }

    /**
     * @param key
     * @return
     */
    public String getParameter(String key) {
        if (this.globalDataMap == null) {
            return null;
        }
        return (String)getObject(key);
    }

    /**
     * @param key
     * @param value
     */
    public void setObject(Object key, Object value) {
        if (this.globalDataMap == null) {
            this.globalDataMap = new HashMap<Object,Object>();
        }
        this.globalDataMap.put(key, value);
    }

    /**
     * @param name
     * @param valueMap
     */
    public void addCondition(String name, HashMap<Object,Object> valueMap){
        setObject(name, valueMap);
    }
}
